<%@ page language="java" contentType="text/html; charset=windows-1255"
	pageEncoding="windows-1255"%>
<%@page import="logic.Reports"%>
<%@page import="data.MovieTuple"%>
<%@page import="java.util.Set"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.sun.org.apache.xalan.internal.xsltc.compiler.sym"%>

<%
	String type = request.getParameter("type");
	String param1 = request.getParameter("p1");
	String param2 = request.getParameter("p2");
	MovieTuple[] movies = null;
	if ((String) session.getAttribute("currentUser") == null) {
		response.sendRedirect("login.jsp");
	}else if (((String) session.getAttribute("type")).equals("user")) {
		response.sendRedirect("userPanel.jsp?Bad");
	} else {
		movies = (type.equals("user") ? Reports.getUserMovies(param1,
				Integer.parseInt(param2)) : Reports.getMovies(Integer
				.parseInt(param1), Boolean.parseBoolean(param2)));
	}
%>

<%@page import="data.RatingTuple"%>
<%@page import="data.SystemData"%><html>
<head>
<title>secret 4 plus dog</title>
<meta http-equiv="Content-Type"
	content="text/html; charset=windows-1255">
<link href="secret4.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#FF6600" dir="ltr">
<a href="login.jsp">Logout</a>    <a href="userPanel.jsp">Main panel</a>
<table height="100%" width="100%" border="0" cellspacing="3"
	cellpadding="2">
	<tr>
		<td width="10%">&nbsp;</td>
		<td valign="top">
		<table height="100%" width="100%" border="0" cellspacing="3"
			cellpadding="2">
			<tr height="20%">
				<td>&nbsp;</td>
			</tr>
			<tr height="80%">
				<td>
				<table align="left" width="100%" border="0" cellspacing="3"
					cellpadding="2">
					<tr>
						<td width="65%" align="left" valign="top">
						<table width="100%" border="0" cellspacing="3" cellpadding="2">
							<tr>
								<td class="title">
								<%
								if (movies!=null){
									out.println((type.equals("user") ? param1
											+ "'s movies rated " + param2+ " and up" : (Boolean
											.parseBoolean(param2) ? "Top " : "Bottom ")
											+ param1 + " movies"));
								}
								%>
								</td>
							</tr>
							<tr>
								<td>
								<table width="100%" border="0" cellspacing="3" cellpadding="2">
									<tr>
										<td>&nbsp;</td>
									</tr>
									<tr>
										<td>
										<table class="bolded" width="100%" border="0" cellspacing="3"
											cellpadding="2">
											<%
											if (movies!=null){
												for (int i= 0 ; i<movies.length ; i++) {
													out.println("<tr>");
													out
															.println("<td class=\"regular\" colspan=\"4\" valign=\"top\">");

													out
															.println("<table width=\"100%\" bordercolor=\"#FF3300\" border=\"1\"");
													out.println("cellspacing=\"3\" cellpadding=\"2\">");
													out.println("<tr>");
													out
															.println("<td class=\"regular\" colspan=\"4\" valign=\"top\">");

													out
															.println("<table width=\"100%\" bordercolor=\"#FF3300\" border=\"1\"");
													out.println("cellspacing=\"3\" cellpadding=\"2\">");
													out.println("<tr>");
													out.println("<td bgcolor=\"#FFCC00\">");
													out
															.println("<table width=\"100%\" border=\"0\" cellspacing=\"3\"");
													out.println("cellpadding=\"2\">");
													out.println("<tr>");
													out.println("<td>Movie:</td>");
													out.println("<td colspan=\"3\"><font style=\"font-weight: bold\"");
													out.println("color=\"#0000FF\">");
													out.println("<a href=\" movieDisplay.jsp?movie="
															+ movies[i].get_name() + "\">"+ movies[i].get_name()+"</a>");
													out.println("</font></td>");
													out.println("</tr>");
													out.println("<tr>");
													out.println("<td>Category:</td>");
													out.println("<td>" + movies[i].get_category() + "</td>");
													out.println("<td>Director:</td>");
													out.println("<td>" + movies[i].get_director() + "</td>");
													out.println("</tr>");
													out.println("<tr>");
													out.println("<td>Language:</td>");
													out.println("<td>" + movies[i].get_language() + "</td>");
													out.println("<td>Length:</td>");
													out.println("<td>" + movies[i].get_length() + " min</td>");
													out.println("</tr>");
													out.println("</table>");
													out.println("</td>");
													out.println("</tr>");
													out.println("<tr>");
													out.println("<td bgcolor=\"#FF9900\">");
													out
															.println("<table width=\"100%\" border=\"0\" cellspacing=\"3\"");
													out.println("cellpadding=\"2\">");
													out.println("<tr>");												
													RatingTuple rating = SystemData.getInstance().getRating(param1,movies[i].get_name());
													if (rating!=null){
														out.println("<td>Rating:</td>");												
														out.println("<td>" + rating.get_rating() + "</td>");
														out.println("<td>Comment:</td>");
														out.println("<td>" + rating.get_description() + "</td>");
													}
													else{
														out.println("<td>Rating:</td>");												
														out.println("<td>" + movies[i].get_rating() + "</td>");
														out.println("<td>Raters:</td>");
														out.println("<td>" + movies[i].get_raters() + "</td>");													
													}
													out.println("</tr>");
													out.println("</table>");
													out.println("</td>");
													out.println("</tr>");
													out.println("</table>");
													out.println("</td>");

													out.println("<td rowspan=\"2\"><img src=\"" + movies[i].get_picture()
															+ "\" width=\"150\"></td>");

													out.println("</tr>");
													out.println("</table>");
													out.println("</td>");

													out.println("</tr>");
												}
											}
											%>
										</table>
										</td>
									</tr>
								</table>
								</td>
							</tr>
						</table>
						</td>
						<td valign="top">&nbsp;</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
		<td width="10%">&nbsp;</td>
	</tr>
</table>

</body>
</html>
